import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { SEntityId } from "../../../../../Message/Public/SEntityId";
import { EEntityType } from "../../../../../Message/Public/EEntityType";
import { Dispatcher } from "../../../../mvc/core/Dispatcher";
import { DataEvent } from "../../../events/DataEvent";
import { EventName } from "../../../mvc/EventName";
import { PetIslandFightResultItemData } from "../PetIslandFightResultItemData";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
//class PetIslandFightResultItemRenderer
    
    export  class PetIslandFightResultItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        /* internal  */onPetNameClick(arg1: Object /* flash.events.TextEvent */): void
        {
            var loc1=null;
            if (this._vo) 
            {
                loc1 = new SEntityId();
                loc1.type = EEntityType._EEntityTypePlayer;
                loc1.typeEx = this._vo.entityId.typeEx;
                loc1.typeEx2 = this._vo.entityId.typeEx2;
                loc1.id = this._vo.entityId.id;
                Dispatcher.dispatchEvent(new DataEvent(EventName.PetIslandGetPetInfo, loc1));
            }
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            if (typeof arg1 === "petislandfightresultitemdata") 
            {
                this._vo = arg1 as PetIslandFightResultItemData;
                this._playerName.text = this._vo.playerName;
                this._life.text = this._vo.life + "/" + this._vo.maxLife;
                this._petName.htmlText = this._vo.guildId > 0 ? Language.getStringByParam(28109, this._vo.petName) : this._vo.petName;
            }
            return;
        }

        protected /* override */ createChildren(): void
        {
            this._petName = ObjCreate.createGTextField("", 0, 2, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER));
            this._playerName = ObjCreate.createGTextField("", 90, 2, 90, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER));
            this._life = ObjCreate.createGTextField("", 180, 2, 105, 20, this, GlobalStyle.setTextFormatAlign(GlobalStyle._textFormat1, flash.text.TextFormatAlign.CENTER));
            this._petName.addEventListener(flash.events.TextEvent.LINK, this.onPetNameClick);
            return;
        }

        /* internal */ /* var */_petName: GTextFiled;

        /* internal */ /* var */_playerName: GTextFiled;

        /* internal */ /* var */_life: GTextFiled;

        /* internal */ /* var */_vo: PetIslandFightResultItemData;
    }
